aggregation groups by terms in group order